package test.san.baseproject.ui.activity

import android.app.Fragment
import android.util.Log
import androidx.appcompat.widget.Toolbar
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.find
import test.san.baseproject.R
import test.san.baseproject.base.BaseAvtivity
import test.san.baseproject.util.FragmentUtil
import test.san.baseproject.util.ToolBarManager

class MainActivity : BaseAvtivity(), ToolBarManager {

    override val toolBar by lazy { find<Toolbar>(R.id.toolbar) }

    private val tag = "MainActivity"

    override fun getLayoutId(): Int {
        return R.layout.activity_main
    }

    override fun initData() {
        initMianToolBar()
    }

    override fun initLister() {
        bottomBar.setOnTabSelectListener {
            Log.e(tag, "it = ${it}")
            val transation = supportFragmentManager.beginTransaction()
            val fragment = FragmentUtil.fragmentUtil.getFragment(it) as androidx.fragment.app.Fragment
            transation.replace(R.id.container, fragment, it.toString())
            transation.commit()
        }
    }
}
